// Copyright (c) rubicon IT GmbH, www.rubicon.eu
//
// See the NOTICE file distributed with this work for additional information
// regarding copyright ownership.  rubicon licenses this file to you under 
// the Apache License, Version 2.0 (the "License"); you may not use this 
// file except in compliance with the License.  You may obtain a copy of the 
// License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
// License for the specific language governing permissions and limitations
// under the License.

using System;
using System.Collections.Generic;
using ActiveAttributes.Model.Ordering;
using ActiveAttributes.Model.Pointcuts;
using Remotion.Utilities;

namespace ActiveAttributes.Model
{
  public interface ICrosscutting
  {
    IPointcut Pointcut { get; }
    IEnumerable<IOrdering> Orderings { get; }

    int Priority { get; }
    Type Type { get; }
    string Role { get; }

    string Name { get; }
  }

  public class Crosscutting : ICrosscutting
  {
    private readonly IPointcut _pointcut;
    private readonly IEnumerable<IOrdering> _orderings;
    private readonly int _priority;
    private readonly Type _type;
    private readonly string _role;
    private readonly string _name;

    public Crosscutting (IPointcut pointcut, IEnumerable<IOrdering> orderings, int priority, Type type, string role)
    {
      ArgumentUtility.CheckNotNull ("pointcut", pointcut);
      ArgumentUtility.CheckNotNull ("orderings", orderings);
      ArgumentUtility.CheckNotNull ("type", type);
      ArgumentUtility.CheckNotNullOrEmpty ("role", role);

      _pointcut = pointcut;
      _orderings = orderings;
      _priority = priority;
      _type = type;
      _role = role;
    }

    public Crosscutting (IPointcut pointcut, IEnumerable<IOrdering> orderings, string name)
    {
      ArgumentUtility.CheckNotNull ("pointcut", pointcut);
      ArgumentUtility.CheckNotNull ("orderings", orderings);
      ArgumentUtility.CheckNotNullOrEmpty ("name", name);

      _pointcut = pointcut;
      _orderings = orderings;
      _name = name;
    }

    public IPointcut Pointcut
    {
      get { return _pointcut; }
    }

    public IEnumerable<IOrdering> Orderings
    {
      get { return _orderings; }
    }

    public int Priority
    {
      get { return _priority; }
    }

    public Type Type
    {
      get { return _type; }
    }

    public string Role
    {
      get { return _role; }
    }

    public string Name
    {
      get { return _name; }
    }
  }
}